package messaage;

public class ErrorMsg extends Message {

	protected String body;

	public ErrorMsg(String _username, String _body) {
		this.username = _username;
		this.body = _body;
	}
	
	public ErrorMsg(String msg){
		parse(msg);
	}

	private void parse(String msg) {
		String [] info = msg.split("\n");
		String [] tempInfo = info[1].split(":");
		this.username = tempInfo[1];
		tempInfo = info[2].split(":");
		this.body = tempInfo[1];
	}

	@Override
	public String toString() {
		String msg = "Error\n" + "Username:"+ this.username+"\nMessage:" + this.body + '\0';
		return msg;
	}
	
	public String getBody(){
		return this.body;
	}

}
